package rdd.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark01_RDD_SUBTRACT {
  def main(args: Array[String]): Unit = {
    val sparkConf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(sparkConf)
    //求相同时间段内的点击数量
    val rdd1: RDD[Int] = sc.makeRDD(List(1, 2,2,3,4,6,7,8, 3, 4, 5,6,7,8,9))
    val rdd: RDD[Int] = sc.makeRDD(List(5,6,7,8,9))
    val distinctRDD: RDD[Int] = rdd.distinct().sortBy(_.unary_+)
    distinctRDD.collect().foreach(println)
    sc.stop()
  }

}
